"""app中xadmin配置"""
import xadmin
from apps.courses.models import Course, Lesson, Video, CourseResource


class GlobalSettings(object):
    """全局xadmin配置"""
    site_title = "慕学后台管理系统"
    site_footer = "慕学在线网"
    menu_style = "accordion"


class BaseSettings(object):
    """全局皮肤配置"""
    enable_themes = True
    use_bootswatch = True


class CourseAdmin(object):
    list_display = ["id", "name", "detail", "degree", "learn_time", "students", "teacher"]
    search_fields = ["name", "detail", "degree", "students"]
    list_filter = ["name", "teacher__name", "desc", "detail", "degree", "learn_time", "students"]
    list_editable = ["degree", "desc"]


class LessonAdmin(object):
    list_display = ["course", "name", "add_time"]
    search_fields = ["course", "name"]
    list_filter = ["course__name", "name", "add_time"]


class VideoAdmin(object):
    list_display = ["lesson", "name", "add_time"]
    search_fields = ["lesson", "name"]
    list_filter = ["lesson", "name", "add_time"]


class CourseResourseAdmin(object):
    list_display = ["course", "name", "file", "add_time"]
    search_fields = ["course", "name", "file"]
    list_filter = ["course", "name", "file", "add_time"]


xadmin.site.register(Course, CourseAdmin)
xadmin.site.register(Lesson, LessonAdmin)
xadmin.site.register(Video, VideoAdmin)
xadmin.site.register(CourseResource, CourseResourseAdmin)

# 注册全局后台配置
xadmin.site.register(xadmin.views.CommAdminView, GlobalSettings)
xadmin.site.register(xadmin.views.BaseAdminView, BaseSettings)
